<!DOCTYPE html>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    
    <title>物业固定资产管理系统</title>
    <meta name="description" content="物业固定资产管理系统">
    <link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
    <link href="../static/css/style.css" th:href="@{/css/style.css}" rel="stylesheet"/>
    <link href="../static/css/login.min.css" th:href="@{/css/login.min.css}" rel="stylesheet"/>
    <link href="../static/ruoyi/css/ry-ui.css" th:href="@{/ruoyi/css/ry-ui.css?v=4.1.0}" rel="stylesheet"/>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <link rel="shortcut icon" href="../static/favicon.ico" th:href="@{favicon.ico}"/>
    <style type="text/css">label.error { position:inherit;  }</style>
    <script>
        if(window.top!==window.self){window.top.location=window.location};
    </script>
</head>

<body class="signin">

    <div class="signinpanel">
        <div class="row">
            <!--<div class="col-sm-7">-->
                <!--<div class="signin-info">-->
                    <!--<div class="logopanel m-b">-->
                        <!--<h1><img alt="[ 固定资产管理系统 ]" src="../static/ruoyi.png" th:src="@{/ruoyi.png}"></h1>-->
                    <!--</div>-->
                    <!--<div class="m-b"></div>-->
                    <!--&lt;!&ndash;<h4>欢迎使用 <strong>固定资产管理系统</strong></h4>&ndash;&gt;-->
                    <!--&lt;!&ndash;<ul class="m-b">&ndash;&gt;-->
                        <!--&lt;!&ndash;<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> SpringBoot</li>&ndash;&gt;-->
                        <!--&lt;!&ndash;<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Mybatis</li>&ndash;&gt;-->
                        <!--&lt;!&ndash;<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Shiro</li>&ndash;&gt;-->
                        <!--&lt;!&ndash;<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Thymeleaf</li>&ndash;&gt;-->
                        <!--&lt;!&ndash;<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Bootstrap</li>&ndash;&gt;-->
                    <!--&lt;!&ndash;</ul>&ndash;&gt;-->
                    <!--&lt;!&ndash;<strong>还没有账号？ <a href="#">立即注册&raquo;</a></strong>&ndash;&gt;-->
                <!--</div>-->
            <!--</div>-->
            <div class="col-sm-7 col-sm-offset-3">
                <form id="signupForm">
                    <h4 class="no-margins">登录：</h4>
                    <!--<p class="m-t-md">你若不离不弃，我必生死相依</p>-->
                    <input type="text"     name="username" class="form-control uname"     placeholder="用户名" value=""    />
                    <input type="password" name="password" class="form-control pword"     placeholder="密码"   value="" />
					<div class="row m-t" th:if="${captchaEnabled==true}">
						<div class="col-xs-6">
						    <input type="text" name="validateCode" class="form-control code" placeholder="验证码" maxlength="5" autocomplete="off">
						</div>
						<div class="col-xs-6">
							<a href="javascript:void(0);" title="点击更换验证码">
								<img th:src="@{captcha/captchaImage(type=${captchaType})}" class="imgcode" width="85%"/>
							</a>
						</div>
					</div>
                    <div class="checkbox-custom" th:classappend="${captchaEnabled==false} ? 'm-t'">
				        <input type="checkbox" checked="checked" id="rememberme" name="rememberme"> <label for="rememberme">记住我</label>
				    </div>
                    <button class="btn btn-success btn-block" id="btnSubmit" data-loading="正在验证登录，请稍后...">登录</button>
                </form>
            </div>
        </div>
        <div class="signup-footer">
            <div class="pull-left">
                &copy; 2019 All Rights Reserved. RuoYi <br>
            </div>
        </div>
    </div>
<script th:inline="javascript"> var ctx = [[@{/}]]; var captchaType = [[${captchaType}]]; </script>
<!-- 全局js -->
<script src="../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
<script src="../static/js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>
<!-- 验证插件 -->
<script src="../static/ajax/libs/validate/jquery.validate.min.js" th:src="@{/ajax/libs/validate/jquery.validate.min.js}"></script>
<script src="../static/ajax/libs/validate/messages_zh.min.js" th:src="@{/ajax/libs/validate/messages_zh.min.js}"></script>
<script src="../static/ajax/libs/layer/layer.min.js" th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script src="../static/ajax/libs/blockUI/jquery.blockUI.js" th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
<script src="../static/ruoyi/js/ry-ui.js" th:src="@{/ruoyi/js/ry-ui.js?v=4.1.0}"></script>
<script>
    $(function() {
        validateKickout();
        validateRule();
        $('.imgcode').click(function() {
            var url = ctx + "captcha/captchaImage?type=" + captchaType + "&s=" + Math.random();
            $(".imgcode").attr("src", url);
        });
    });

    $.validator.setDefaults({
        submitHandler: function() {
            login();
        }
    });

    function login() {
        $.modal.loading($("#btnSubmit").data("loading"));
        var username = $.common.trim($("input[name='username']").val());
        var password = $.common.trim($("input[name='password']").val());
        var validateCode = $("input[name='validateCode']").val();
        var rememberMe = $("input[name='rememberme']").is(':checked');
        $.ajax({
            type: "post",
            url: ctx + "login",
            data: {
                "username": username,
                "password": password,
                "validateCode" : validateCode,
                "rememberMe": rememberMe
            },
            success: function(r) {
                if (r.code == 0) {
                    var ua = navigator.userAgent;

                    var ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
                        isIphone =!ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),

                        isAndroid = ua.match(/(Android)\s+([\d.]+)/),
                        isMobile = isIphone || isAndroid;
                    if(isMobile) {
                        var str='[[${reqUrl}]]';
                        while (str.indexOf('&quot;')!=-1){
                            str=str.replace("&quot;",'"');
                        }
                        location.href =JSON.parse(str).requestURI;
                    }else{
                        location.href = ctx + 'index';
                    }
                } else {
                    $.modal.closeLoading();
                    $('.imgcode').click();
                    $(".code").val("");
                    $.modal.msg(r.msg);
                }
            }
        });
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                username: {
                    required: true
                },
                password: {
                    required: true
                }
            },
            messages: {
                username: {
                    required: icon + "请输入您的用户名",
                },
                password: {
                    required: icon + "请输入您的密码",
                }
            }
        })
    }

    function validateKickout() {
        if (getParam("kickout") == 1) {
            layer.alert("<font color='red'>您已在别处登录，请您修改密码或重新登录</font>", {
                    icon: 0,
                    title: "系统提示"
                },
                function(index) {
                    //关闭弹窗
                    layer.close(index);
                    if (top != self) {
                        top.location = self.location;
                    } else {
                        var url  =  location.search;
                        if (url) {
                            var oldUrl  = window.location.href;
                            var newUrl  = oldUrl.substring(0,  oldUrl.indexOf('?'));
                            self.location  = newUrl;
                        }
                    }
                });
        }
    }

    function getParam(paramName) {
        var reg = new RegExp("(^|&)" + paramName + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]);
        return null;
    }
</script>
</body>
</html>
